{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "操作系统名称: posix\n",
      "当前工作目录: /home/shenyc/sfxCode/py-study/notebook\n",
      "是否是绝对路径: False\n",
      "是否为目录: False\n",
      "是否为文件: True\n",
      "是否为存在: True\n",
      "返回文件大小: 1795147\n",
      "返回绝对路径: /home/shenyc/sfxCode/py-study/data/FY4A_L2_DLR_20190306_4000M.NC\n"
     ]
    }
   ],
   "source": [
    "# os\n",
    "#\n",
    "import os\n",
    "\n",
    "# print(os)\n",
    "print(\"操作系统名称: %s\" % os.name)\n",
    "print(\"当前工作目录: %s\" % os.getcwd())\n",
    "# 执行命令： os.system(‘命令行’)\n",
    "\n",
    "\n",
    "# 路径相关函数：\n",
    "pf = '../data/FY4A_L2_DLR_20190306_4000M.NC'\n",
    "print(\"是否是绝对路径: %s\" % os.path.isabs(pf))\n",
    "print(\"是否为目录: %s\" % os.path.isdir(pf))\n",
    "print(\"是否为文件: %s\" % os.path.isfile(pf))\n",
    "print(\"是否为存在: %s\" % os.path.exists(pf))\n",
    "print(\"返回文件大小: %s\" % os.path.getsize(pf))\n",
    "print(\"返回绝对路径: %s\" % os.path.abspath(pf))\n",
    "\n",
    "# 文件和文件夹相关：\n",
    "# os.remove(path) 删除指定的文件\n",
    "# os.rename(src,dest) 重命名文件或目录\n",
    "# os.stat(path) 返回文件的所有属性\n",
    "# os.listdir(path) 返回path目录下的文件和目录列表\n",
    "# os.mkdir(path) 创建目录\n",
    "# os.makedirs(path1/path2/path3/…) 创建多级目录\n",
    "# os.rmdir(path) 删除目录\n",
    "# os.removedirs(path1/path2/path3/…) 删除多级目录\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.6 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
